export default {
	data() {
		return {
			MaintenanceMethod: [{
				text: "请选择保养方式",
				value: 0
			}, {
				text: "单清洗",
				value: 1
			}, {
				text: "单保养",
				value: 2
			}, {
				text: "保养+清洗",
				value: 3
			}, {
				text: "不保养+不清洗",
				value: 4
			}],
			maintenanceIndex: 0,
			CtrlMaintainRow: 0,
			woProducts: [],
			woTransInfo: {},
			woCacheData: {},
		}
	},
	methods: {
		//获取工单数据
		async GetOrderData() {
			let result = await this.workorderlistervice.CacheOrderInfoAsync(this.UserInfo.mobile, 2, this.orderDetailId, "",
				this.UserInfo.RetId);
			if (result) {
				if (result.RetBool) {
					let data = JSON.parse(result.RetObject);
					//this.orderDetailData = JSON.parse(data.NewWoData);
					let orderDetailData = JSON.parse(data.NewWoData);
					//完工处理信息
					this.orderDetailData = orderDetailData;
					console.log(orderDetailData);

					//this.initData(orderDetailData);
					//if(data.CacheWoData)
					//this.orderDataCache = data.CacheWoData;					
				} else {
					uni.showToast({
						title: $ `获取工单信息失败${result.RetMsg}`,
						icon: "none"
					});
				}
			} else {
				uni.showToast({
					title: "获取工单信息失败!",
					icon: "none"
				});
			}
			uni.hideLoading();
		},

		firstChar(str) {
			if (str)
				return str.charAt(0);
			else
				return ""
		},

		//验证物理码
		async BarcodeValidCheckAsync(index, Barcode) {
			let userPhone = this.UserInfo.mobile
			let token = this.UserInfo.RetId
			let result = await this.workordercompleteservice
				.BarcodeValidCheckAsync(userPhone, Barcode, token);
			if (result && result.RetBool) {
				let data = JSON.parse(result.RetObject);
				return data;
			} else {
				console.log(result.RetMsg);
				throw result.RetMsg;
			}
		},

		async GetOrderDataImg() {
			let UsePhone = this.UserInfo.mobile;
			let token = this.UserInfo.RetId

			let result = await this.workorderlistervice.CacheOrderInfoAsync(UsePhone, 2,
				this.orderDetailId, "",
				token);
			if (result && result.RetBool) {
				let data = JSON.parse(result.RetObject);
				let orderDetailData = JSON.parse(data.NewWoData);
				return orderDetailData.WoItemPicture;
			}

		},

		getImageBase64(itempic) {
			let srcbase64 = `data:image/${itempic.FileType.replace('.','')};base64,${itempic.ImageContent}`;
			return srcbase64;
		},

		getImage(image) {
			return (image != null && image != 'null' && image != '') ?
				"data:image/jpeg;base64," + image : "";
		},

		//获取保养滤芯列表
		async GetProductMaintainInfo(PurchaseDate, CustEquipmentGuid, IsComfirmed, ProductGuid) {
			//debugger
			console.log("产品", ProductGuid);
			let result = await this.workordercompleteservice
				.GetPartsMaintainInfoAsync(this.UserInfo.mobile, PurchaseDate, CustEquipmentGuid, IsComfirmed, ProductGuid, this.UserInfo
					.RetId);
			console.log(result);
			debugger
			if (result && result.RetBool) {
				if (result.RetObject) {
					let data = JSON.parse(result.RetObject);
					return data;
				}
			}
			return null;
		},


		//  GetProductMaintainData(PurchaseDate, CustEquipmentGuid, IsComfirmed, ProductGuid) {
		// 	debugger
		// 	this.workordercompleteservice.GetPartsMaintainInfoAsync(this.UserInfo.mobile, PurchaseDate, CustEquipmentGuid,
		// 		IsComfirmed, ProductGuid, this.UserInfo.RetId).then(result => {
		// 		console.log(result);
		// 		debugger
		// 		if (result.RetBool == true) {
		// 			let data = JSON.parse(result.RetObject);
		// 			// fp_ProInfoItem.ProductMaintainInfo = data;
		// 			return data;
		// 			// this.reservationReason = data;
		// 		} else {
		// 			uni.showToast({
		// 				title: result.RetMsg,
		// 				icon: "none"
		// 			});
		// 			return null;
		// 		}
		// 	});
		// },

		//解析数据
		initData(WoData) {
			debugger;
			//赋值工单头数据
			this.AssignOrderInfo(WoData);
			var tempWoFinishedProList = [];
			//debugger;
			if (WoData.ShelfLife == 1)
				this.isShowActualReceiptAmountField = true;
			for (let index in WoData.WoProuduct) {
				//物流码
				let itemPro = WoData.WoProuduct[index]
				let result = this.IsLogisticsCodeAndProductFill(itemPro, WoData);
				let fp_ProInfoItem = {
					'WoObjectId': itemPro.WoObjectId,
					'proHisNum': itemPro.ProductNum,
					'proHisId': itemPro.ProuctId,
					'proHisTypeGroup': itemPro.ProdTypeGroup,
					'proHisName': itemPro.ProductName,
					'proHisPurchaseSourceName': itemPro.PurchaseSourceText,
					'proHisPurchaseStoreName': itemPro.PurchaseChanel,
					'proHisBarcode': itemPro.Barcode,
					'proHisIsValidBarcode': itemPro.IsSerialValid,
					'proHisPurchaseDate': itemPro.PurchaseDate,
					'ProductNum': itemPro.ProductNum,
					'ProuctId': itemPro.ProuctId,
					'ProdTypeGroup': itemPro.ProdTypeGroup,
					'ProductName': itemPro.ProductName,
					'PurchaseSourceText': itemPro.PurchaseSourceText,
					'InstallLocation': itemPro.InstallLocation,
					'PurchaseChanel': itemPro.PurchaseChanel,
					'PurchaseDate': itemPro.PurchaseDate,
					'Barcode': itemPro.Barcode,
					'IsSerialValid': itemPro.IsSerialValid,
					'ProductImage': itemPro.ProductImage,
					'IsProductConfirmed': itemPro.IsProductConfirmed,
					'proOriBarcode': itemPro.Barcode,
					'isBarcodeRequired': result.isBarcodeRequired,
					'isCheckBarcode': result.isCheckBarcode,
					'isShowBarcodeCheckBtn': false,
					'isDisplayProdInputField': result.isDisplayProdInputField,
					'isDisplayNewProdInputField': true,
					'isShowNewBarcodeCheckBtn': false,
					'proNewInstallPosition': null,
					'proIsNewBarcodeRequired': result.isBarcodeRequired,
					'proIsCheckNewBarcode': false,
					'proNewBarcode': null,
					'proNewProductID': null,
					'proNewProductName': null,
					'proNewProductNum': null,
					'proOriNewBarcode': null,
					'proCustProdID': itemPro.CustProductId,
					'WaterAnalysisFieldRequired': itemPro.WaterAnalysisFieldRequired,
					'OriWaterAnalysisId': itemPro.OriWaterAnalysisId,
					'ProductSeriesId': itemPro.ProductSeriesId,
					'ProductSeriesName': itemPro.ProductSeriesName,
					'OriTDS': itemPro.OriTDS,
					'OriTemperature': itemPro.OriTemperature,
					'OriHardness': itemPro.OriHardness,
					'OriChlorine': itemPro.OriChlorine,
					'NewTDS': itemPro.NewTDS,
					'NewHardness': itemPro.NewHardness,
					'NewChlorine': itemPro.NewChlorine,
					'IsRequired': itemPro.IsRequired,
					'IsWaterAnalysis': false,
					'isShowWaterAnalysisAddBtn': (!itemPro.OriWaterAnalysisId&&!itemPro.IsShowWaterAnalysisAddBtn) ? false : true,
					'WarrantyEndDate': itemPro.WarrantyEndDate,
					'WarrantyStartDate': itemPro.WarrantyStartDate,
					'SuitProductName': itemPro.SuitProductName,
					'SuitProductDescription': itemPro.SuitProductDescription,
					'OnlyChangeEndDate': itemPro.OnlyChangeEndDate,
					'maintenanceIndex': itemPro.MaintainType ? itemPro.MaintainType : 0,
					'ProductMaintainData': itemPro.Maintains ? itemPro.Maintains : null,
				};
				tempWoFinishedProList.push(fp_ProInfoItem)
			}
			WoData.WoProuduct = tempWoFinishedProList;

		},

		IsLogisticsCodeAndProductFill(itemPro, woData) {
			//物流码是否可填
			let isBarcodeRequired = false;
			//产品是否可填
			let isDisplayProdInputField = true;
			//
			let isCheckBarcode = false;
			if (itemPro.IsProductConfirmed == false) {
				// ShelfLife【1：保外；2：保内；3：保外转保内】
				// InWarrantySerialCtrl；OutWarrantySerialCtrl【1：不验证；2：工单完工验证；3：产品确认验证】
				console.log("保内保外：", woData.ShelfLife);
				console.log("保内控制：", woData.InWarrantySerialCtrl);
				console.log("保外控制：", woData.OutWarrantySerialCtrl);
				if (woData.ShelfLife == 1 && woData.InWarrantySerialCtrl != 1) {
					isBarcodeRequired = true;
				} else if (woData.ShelfLife == 2 && woData.OutWarrantySerialCtrl != 1) {
					isBarcodeRequired = true;
				} else {
					isDisplayProdInputField = false;
				}
			} else {
				isCheckBarcode = true;
			}
			return {
				isBarcodeRequired: isBarcodeRequired,
				isDisplayProdInputField: isDisplayProdInputField,
				isCheckBarcode: isCheckBarcode
			};
		},
		//解析水质检测必填项
		ParseWaterAnalysisFieldRequired(strWaterAnalysisFieldRequired) {
			if (strWaterAnalysisFieldRequired != null && strWaterAnalysisFieldRequired != "") {
				let objFieldRequired = {};
				let listItem = strWaterAnalysisFieldRequired.split("|");
				for (let j = 0; j < listItem.length; j++) {
					let strItem = listItem[j];
					let field = strItem.split("=");
					if (field[0] == "OriTDS") {
						objFieldRequired.OriTDS = (field[1] == 1) ? true : false;
					} else if (field[0] == "OriTemperature") {
						objFieldRequired.OriTemperature = (field[1] == 1) ? true : false;
					} else if (field[0] == "OriHardness") {
						objFieldRequired.OriHardness = (field[1] == 1) ? true : false;
					} else if (field[0] == "OriChlorine") {
						objFieldRequired.OriChlorine = (field[1] == 1) ? true : false;
					} else if (field[0] == "NewTDS") {
						objFieldRequired.NewTDS = (field[1] == 1) ? true : false;
					} else if (field[0] == "NewHardness") {
						objFieldRequired.NewHardness = (field[1] == 1) ? true : false;
					} else if (field[0] == "NewChlorine") {
						objFieldRequired.NewChlorine = (field[1] == 1) ? true : false;
					}
				}
				return objFieldRequired;
			} else {
				return null;
			}
		},
		//获取保养信息
		GetMaintainInfoFromServer(itemPro, index) {
			//debugger;
			console.log(itemPro);
			console.log(itemPro.ProuctId);

			this.GetProductMaintainInfo(itemPro.PurchaseDate, itemPro.proCustProdID,
				itemPro.IsProductConfirmed, itemPro.ProuctId).then((ProductMaintainData) => {
				if (ProductMaintainData) {
					itemPro.ProductMaintainData = [];
					for (let Minindex in ProductMaintainData) {
						let itemMaintain = ProductMaintainData[Minindex];
						let isDisabledReplacePurchasedByOneself = true; //是否禁用自购件选择
						let woIsPurchasedByOneself = this.orderDetailData.IsSincePurchase;
						if (itemMaintain.IsAllowCustomBuy && woIsPurchasedByOneself) {
							isDisabledReplacePurchasedByOneself = false;
						}
						let rowMaintain = {
							IsNewAddRow: false,
							FilterPartTypeName: itemMaintain.AppBrief,
							FilterPartTypeID: itemMaintain.FilterTypeId,
							HisFilterPartTypeName: itemMaintain.AppBrief,
							HisFilterPartTypeID: itemMaintain.FilterTypeId,
							FilterPartUsedCost: itemMaintain.HadUsed,
							FilterPartUnUsedCost: itemMaintain.Remainder,
							HisFilterPartID: itemMaintain.PartsGuid,
							HisFilterPartNum: itemMaintain.PartsNum,
							HisFilterPartName: itemMaintain.PartsName,
							FilterPartID: itemMaintain.PartsGuid,
							FilterPartNum: itemMaintain.PartsNum,
							FilterPartName: itemMaintain.PartsName,
							FilterPartImg: null,
							FilterPartPrice: "",
							FilterPartInventory: null,
							FilterPartMaintainPeriod: null,
							IsReplaceFilterPart: false,
							IsReplacePurchasedByOneself: false,
							IsDisabledReplacePurchasedByOneself: isDisabledReplacePurchasedByOneself,
							AssemblyBomGuid: itemMaintain.AssemblyBomGuid,
							ProductBomGuid: itemMaintain.ProductBomGuid
						};
						itemPro.ProductMaintainData.push(rowMaintain);
					}

					this.productMaintainData.splice(index, 1, itemPro.ProductMaintainData);
				}
			}, (err) => {
				console.log(err);
			});


		},
		//验证后刷新产品信息
		RefreshProduct(data, index, Barcode) {
			//debugger;
			let productItem = this.orderDetailData.WoProuduct[index];
			if (data && data.IsValid) {
				//debugger
				productItem.Barcode = Barcode;
				productItem.IsSerialValid = "有效";
				if (data.ItemIdGUID) {
					productItem.ProductNum = data.ProductName;
					productItem.ProductName = data.ProductNum;
					productItem.ProuctId = data.ItemIdGUID;
					productItem.ProdTypeGroup = data.ProductTypeGroupName;
					productItem.WaterAnalysisFieldRequired = data.WaterAnalysisFieldRequired;
					productItem.ProductImage = data.ProductImage;
					productItem.proFaultyGroup = data.FaultyGroup;
					productItem.proFaultyGroupName = data.FaultyGroupName;
					productItem.IsRequired = data.IsRequired;
					productItem.isCheckBarcode = true;
					productItem.isDisplayProdInputField = true;
					uni.hideLoading();
				} else {
					productItem.isCheckBarcode = true;
					productItem.isDisplayProdInputField = false;
					uni.hideLoading();
					uni.showToast({
						title: "物流码有效，但没有匹配到关联产品，请从产品选择",
						icon: "none",
						duration: 3000
					});
				}
			} else {
				productItem.Barcode = "";
				uni.hideLoading();
				uni.showToast({
					title: "物流码无效，请重新输入",
					icon: "none",
					duration: 3000
				});
			}
		},
		//检测打开保养信息页面
		CheckAddMaintainInfo(woProItem) {
			let woObjectId = woProItem.WoObjectId;
			let proIsConfirmed = woProItem.IsProductConfirmed;
			let isBarcodeRequired = woProItem.isBarcodeRequired;
			if (!proIsConfirmed) {
				let proBarcode = woProItem.Barcode;
				if (proBarcode) {
					let isCheckBarcode = woProItem.isCheckBarcode;
					if (!isCheckBarcode) {
						//ShowAlertMsg("信息提示", "请先验证输入的物流码有效再添加维修信息！");
						uni.showToast({
							title: "请先验证输入的物流码有效再添加保养信息！",
							icon: "none",
							duration: 3000,
						});
						return false;
					}
				} else if (isBarcodeRequired && (proBarcode == null || proBarcode == "")) {
					//ShowAlertMsg("信息提示", "请先填写物流码并验证有效后再添加维修信息！");
					uni.showToast({
						title: "请先填写物流码并验证有效后再添加保养信息！",
						icon: "none",
						duration: 3000,
					});
					return false;
				}
				let proId = woProItem.ProuctId;
				if (!proId) {
					uni.showToast({
						title: "请先选择产品再添加保养信息！",
						icon: "none",
						duration: 3000,
					});
					return false;
				}
				let proPurchaseDate = woProItem.PurchaseDate;
				if (!proPurchaseDate) {
					uni.showToast({
						title: "请先选择产品购机日期再添加保养信息！",
						icon: "none",
						duration: 3000,
					});
					return false;
				}
				return true;
			} else {
				let woProdId = woProItem.ProuctId;
				if (!woProdId) {
					uni.showToast({
						title: "数据异常，已确认的产品ID为空！",
						icon: "none",
						duration: 3000,
					});
					return false;
				} else {
					return true;
				}
			}
		},
		//汇总保养配件的个数和保外费用
		AggregateMaintainPartData(woPordItem) {
			debugger;
			//let listMaintainInfo = woPordItem.ListMaintainInfo;
			let listMaintainInfo = woPordItem.ProductMaintainData;
			let valMaintainPartCount = 0;
			let valMaintainPartAmount = 0;
			if (listMaintainInfo && listMaintainInfo.length > 0) {
				for (let i in listMaintainInfo) {
					let itemMaintainInfo = listMaintainInfo[i];
					let isReplaceFilterPart = itemMaintainInfo.IsReplaceFilterPart;
					if (isReplaceFilterPart == true) {
						let valFilterPartPrice = (itemMaintainInfo.FilterPartPrice == null) ? 0 : itemMaintainInfo.FilterPartPrice;
						valMaintainPartCount = valMaintainPartCount + 1;
						let _valWoShelfLife = this.orderDetailData.ShelfLife;
						if (_valWoShelfLife == 1) {
							// 只汇总保外配件费用
							valMaintainPartAmount = valFilterPartPrice - 0 + valMaintainPartAmount;
						}
					}
				}
				woPordItem.MaintainPartCount = valMaintainPartCount;
				woPordItem.MaintainPartAmount = valMaintainPartAmount;
			}
		},
		//绑定保养列表
		BindMaintainList(BulkMianList, index) {
			let itemPro = this.orderDetailData.WoProuduct[index];
			if (BulkMianList) {
				if ((itemPro.ProductMaintainData && itemPro.ProductMaintainData.length == 0) || !itemPro.ProductMaintainData) {
					for (let i in BulkMianList) {
						let itemMaintain = BulkMianList[i];
						let rowMaintain = {
							IsNewAddRow: true,
							FilterPartTypeName: itemMaintain.AppBrief,
							FilterPartTypeID: itemMaintain.FilterTypeId,
							FilterPartID: itemMaintain.PartsGuid,
							FilterPartNum: itemMaintain.PartsNum,
							FilterPartName: itemMaintain.PartsName,
							FilterPartImg: null,
							FilterPartPrice: itemMaintain.Price,
							FilterPartInventory: itemMaintain.SiteStock,
							FilterPartMaintainPeriod: itemMaintain.MaintainPeriod,
							FilterPartUsedCost: 0,
							FilterPartUnUsedCost: 0,
							IsReplaceFilterPart: true,
							IsReplacePurchasedByOneself: false,
							IsDisabledReplacePurchasedByOneself: true,
						};
						itemPro.ProductMaintainData.push(rowMaintain);
					}
					this.productMaintainData.splice(index, 1, itemPro.ProductMaintainData);

				} else {
					//同类型的滤芯则替换，不同类型的滤芯则新增
					for (let i in BulkMianList) {
						let newMainItem = BulkMianList[i];
						let strFilterPartTypeID = newMainItem.FilterTypeId;
						let hasReplace = false;
						for (let j in itemPro.ProductMaintainData) {
							let mainItem = itemPro.ProductMaintainData[j];
							let oriFilterPartTypeID = mainItem.FilterPartTypeID;
							let oriIsReplaceFilterPart = mainItem.IsReplaceFilterPart;
							if (!oriIsReplaceFilterPart && oriFilterPartTypeID == strFilterPartTypeID) {
								mainItem.FilterPartTypeName = newMainItem.AppBrief;
								mainItem.FilterPartTypeID = newMainItem.FilterTypeId;
								mainItem.FilterPartID = newMainItem.PartsGuid;
								mainItem.FilterPartNum = newMainItem.PartsNum;
								mainItem.FilterPartName = newMainItem.PartsName;
								mainItem.FilterPartPrice = newMainItem.Price;
								mainItem.IsReplaceFilterPart = true;
								mainItem.IsReplacePurchasedByOneself = false;
								hasReplace = true;
								console.log("保养信息", mainItem);
								break;
							}
						}
						console.log("保养列表", itemPro.ProductMaintainData);
						if (!hasReplace) {
							let rowMaintain = {
								IsNewAddRow: true,
								FilterPartTypeName: itemMaintain.AppBrief,
								FilterPartTypeID: itemMaintain.FilterTypeId,
								FilterPartID: itemMaintain.PartsGuid,
								FilterPartNum: itemMaintain.PartsNum,
								FilterPartName: itemMaintain.PartsName,
								FilterPartImg: null,
								FilterPartPrice: itemMaintain.Price,
								FilterPartInventory: itemMaintain.SiteStock,
								FilterPartMaintainPeriod: itemMaintain.MaintainPeriod,
								FilterPartUsedCost: 0,
								FilterPartUnUsedCost: 0,
								IsReplaceFilterPart: true,
								IsReplacePurchasedByOneself: false,
								IsDisabledReplacePurchasedByOneself: true,
							};
							itemPro.ProductMaintainData.push(rowMaintain);
						}
					}
					this.AggregateMaintainPartData(itemPro);
					this.productMaintainData.splice(index, 1, itemPro.ProductMaintainData);
				}
			}
		},
		//提交工单
		async SubmitOrder() {
			uni.showLoading({
				title: "提交中..",
				mask: true,
			})
			//数据检测
			let IsAllValid = this.CheckDataBySubmitFinish();
			if (IsAllValid) {
				this.ConstructWoSubmitDataObject(); //构建完工对象
				let strCacheData = this.GetCacheOrderInfo(); //构建缓存对象
				console.log(this.woProducts, this.woTransInfo)
				let result = await this.workordercompleteservice.WOSubmitActionAsync(this.UserInfo.mobile, this.woTransInfo, this.woProducts,
					strCacheData, this.UserInfo.RetId)
				uni.hideLoading();
				if (result) {
					if (result.RetBool) {
						uni.showToast({
							title: "提交完工成功",
							icon: "none",
							duration: 3000
						});
						uni.switchTab({
							url: '../../workorder/index',
							success: () => {
								uni.$emit("ReLoadWorder");
							}
						});
					} else {
						uni.showToast({
							title: "提交完工失败:" + result.RetMsg,
							icon: "none",
							duration: 3000
						});
					}
				} else {
					uni.showToast({
						title: "提交完工失败",
						icon: "none",
						duration: 3000
					});
				}
			}

		},
		//完工数据检测
		CheckDataBySubmitFinish() {
			let toastduration = 3000
			//完工备注
			if (this.OrderRremark != "") {
				let IsContainSpecial = this.CheckSpecial(this.OrderRremark);
				if (IsContainSpecial) {
					uni.showToast({
						title: "完工备注不能包含如下特殊字符(%()\;:\'\",.\\/)",
						icon: "none",
						duration: toastduration
					});
					return false;
				}
			}
			//验证产品选择、物流码输入字段、购机日期、装机位置
			for (let index in this.orderDetailData.WoProuduct) {
				let ProductItem = this.orderDetailData.WoProuduct[index];
				let proIsConfirmed = ProductItem.IsProductConfirmed
				let proBarcode = ProductItem.Barcode;
				let proNum = ProductItem.ProductNum;
				let isBarcodeRequired = ProductItem.IsBarcodeRequired;
				//let proInstallPosition = ProductItem.InstallLocation;
				let proPurchaseDate = ProductItem.PurchaseDate;
				if (!proIsConfirmed) {
					let proId = ProductItem.ProuctId;
					if (proId == null || proId == "") {
						uni.showToast({
							title: "产品字段不能为空值，请选择！",
							icon: "none",
							duration: 10000
						});
						return false;
					}
					if (proBarcode && proBarcode != "") {
						let isCheckBarcode = ProductItem.isCheckBarcode;
						if (isCheckBarcode != true) {
							uni.showToast({
								title: `产品：${proNum}输入的物流码未验证！`,
								icon: "none",
								duration: 10000
							});
							return false;
						}
					} else if (isBarcodeRequired == true && (proBarcode == null || proBarcode == "")) {
						uni.showToast({
							title: `产品：${proNum}物流码不能为空！`,
							icon: "none",
							duration: 10000
						});
						return false;
					}
				}
				if (proBarcode != null && proBarcode != "") {
					let isContainSpecial = this.CheckSpecial(proBarcode);
					if (isContainSpecial == true) {
						uni.showToast({
							title: '物流码不能包含如下特殊字符',
							icon: "none",
							duration: 10000
						});
						return false;
					}
				}
				if (proPurchaseDate == null || proPurchaseDate == "") {
					uni.showToast({
						title: `产品：${proNum}购机日期不能为空！`,
						icon: "none",
						duration: 10000
					});
					return false;
				}
				//保养信息检测
				let valMaintainWay = ProductItem.maintenanceIndex;
				if (valMaintainWay == 0) {
					uni.showToast({
						title: `产品：${proNum}未选择保养类型！`,
						icon: "none",
						duration: 10000
					});
					return false;
				}
				debugger;
				let valCtrlMaintainRow = this.orderDetailData.CtrlMaintainRow ? this.orderDetailData.CtrlMaintainRow : 0; // 1：不可用；2：可用；3：必须
				if (valCtrlMaintainRow == 3) {
					if (valMaintainWay == 2 || valMaintainWay == 3) {
						if (!ProductItem.ProductMaintainData || ProductItem.ProductMaintainData.length == 0) {
							uni.showToast({
								title: `产品：${proNum}请添加保养信息行！`,
								icon: "none",
								duration: 10000
							});
							return false;
						}
					}
					let prodMaintainList = ProductItem.ProductMaintainData;
					// 遍历是否存在保养换件行
					let isExistReplaceFilterPart = false;
					for (let j in prodMaintainList) {
						let itemMaintain = prodMaintainList[j];
						let IsReplaceFilterPart = itemMaintain.IsReplaceFilterPart ? itemMaintain.IsReplaceFilterPart : false;
						if (IsReplaceFilterPart == true) {
							isExistReplaceFilterPart = true;
							break;
						}
					}
					if (valMaintainWay == 2 || valMaintainWay == 3) {
						if (!isExistReplaceFilterPart) {
							uni.showToast({
								title: `该保养类型必须为产品：${proNum}更换滤芯才能提交完工！`,
								icon: "none",
								duration: 10000
							});
							return false;
						}
					} else if (isExistReplaceFilterPart) {
						uni.showToast({
							title: `该保养类型不需要为产品：${proNum}更换滤芯，请修改后再提交完工！`,
							icon: "none",
							duration: 10000
						});
						return false;
					}
				}
				//水质检测字段检测
				if (ProductItem.IsRequired == true && ProductItem.IsWaterAnalysis == false) {
					uni.showToast({
						title: `产品：${proNum}未填写水质检测信息！`,
						icon: "none",
						duration: toastduration
					});
					return false;
				}
				if (ProductItem.IsRequired == true) {
					let strWaterAnalysisFieldRequired = ProductItem.WaterAnalysisFieldRequired;
					let objFieldRequired = this.ParseWaterAnalysisFieldRequired(strWaterAnalysisFieldRequired);
					if (objFieldRequired != null) {
						if (objFieldRequired.OriTDS == true && (ProductItem.OriTDS == null || ProductItem.OriTDS == "")) {
							uni.showToast({
								title: `产品：${proNum}水质检测项“原水TDS”为必填项，请填写后再提交完工！`,
								icon: "none",
								duration: toastduration
							});
							return false;
						}
						if (objFieldRequired.OriTemperature == true && (ProductItem.OriTemperature == null || ProductItem.OriTemperature ==
								"")) {
							uni.showToast({
								title: `产品：${proNum}水质检测项“原水水温”为必填项，请填写后再提交完工！`,
								icon: "none",
								duration: toastduration
							});
							return false;
						}
						if (objFieldRequired.OriHardness == true && (ProductItem.OriHardness == null || ProductItem.OriHardness == "")) {
							uni.showToast({
								title: `产品：${proNum}水质检测项“原水硬度”为必填项，请填写后再提交完工！`,
								icon: "none",
								duration: toastduration
							});
							return false;
						}
						if (objFieldRequired.OriChlorine == true && (ProductItem.OriChlorine == null || ProductItem.OriChlorine == "")) {
							uni.showToast({
								title: `产品：${proNum}水质检测项“原水余氯”为必填项，请填写后再提交完工！`,
								icon: "none",
								duration: toastduration
							});
							return false;
						}
						if (objFieldRequired.NewTDS == true && (ProductItem.NewTDS == null || ProductItem.NewTDS == "")) {
							uni.showToast({
								title: `产品：${proNum}水质检测项“纯水TDS”为必填项，请填写后再提交完工！`,
								icon: "none",
								duration: toastduration
							});
							return false;
						}
						if (objFieldRequired.NewHardness == true && (ProductItem.NewHardness == null || ProductItem.NewHardness == "")) {
							uni.showToast({
								title: `产品：${proNum}水质检测项“软化后硬度”为必填项，请填写后再提交完工！`,
								icon: "none",
								duration: toastduration
							});
							return false;
						}
						if (objFieldRequired.NewChlorine == true && (ProductItem.NewChlorine == null || ProductItem.NewChlorine == "")) {
							uni.showToast({
								title: `产品：${proNum}水质检测项“净化后余氯”为必填项，请填写后再提交完工！`,
								icon: "none",
								duration: toastduration
							});
							return false;
						}
					}
				}
				//
			}
			// 验证实际收款总金额字段
			if (this.isShowActualReceiptAmountField == true) {
				let valAmount = this.ActualReceiptAmount;
				if (!valAmount) {
					uni.showToast({
						title: "实际收款总金额不能为空！",
						icon: "none"
					});
					return false;
				}
			}
			return true;
		},
		//构造工单完工提交数据对象
		ConstructWoSubmitDataObject() {
			debugger;
			this.woTransInfo = {};
			this.woProducts = [];
			this.woTransInfo.ServiceOrder = this.orderDetailId;
			this.woTransInfo.Operator = ""; // 操作服务工程师
			this.woTransInfo.Type = 20; // 工单事务类型
			this.woTransInfo.FinishType = this.orderDetailData.WoFinishType; // 完工类型
			this.woTransInfo.Description = this.OrderRremark //备注
			this.woTransInfo.RepairType = "";
			this.woTransInfo.IsRepalced = false;
			this.woTransInfo.ActualReceivedAmount = this.ActualReceiptAmount;
			this.woTransInfo.CustomerRequiresMaintenanceDate = this.CustomerRequiresMaintenanceDate;
			for (let index in this.orderDetailData.WoProuduct) {
				let prodItem = this.orderDetailData.WoProuduct[index];
				let maintains = []; //保养列表
				if (prodItem.ProductMaintainData) {
					for (let i in prodItem.ProductMaintainData) {
						let mainItem = prodItem.ProductMaintainData[i];
						if (mainItem.IsReplaceFilterPart) {
							var maintain = {
								FilterLocation: "",
								OldFilter: mainItem.HisFilterPartID ? mainItem.HisFilterPartID : "",
								OldFiltersName: mainItem.HisFilterPartName ? mainItem.HisFilterPartName : "",
								OldFilterType: mainItem.HisFilterPartTypeID ? mainItem.HisFilterPartTypeID : "",
								OldFilterAssemblybom: mainItem.AssemblyBomGuid ? mainItem.AssemblyBomGuid : "",
								Filters: mainItem.FilterPartID ? mainItem.FilterPartID : "",
								FilterName: mainItem.FilterPartName ? mainItem.FilterPartName : "",
								NewFilterType: mainItem.FilterPartTypeID ? mainItem.FilterPartTypeID : "",
								IsChangeCustomHavedFilter: mainItem.IsReplacePurchasedByOneself
							};
							maintains.push(maintain);
						}
					}
				}
				let waterAnalysis = {
					OriWaterAnalysisId: prodItem.OriWaterAnalysisId,
					OriTDS: prodItem.OriTDS,
					OriTemperature: prodItem.OriTemperature,
					OriHardness: prodItem.OriHardness,
					OriChlorine: prodItem.OriChlorine,
					NewTDS: prodItem.NewTDS,
					NewHardness: prodItem.NewHardness,
					NewChlorine: prodItem.NewChlorine,
					IsWaterAnalysis: prodItem.IsWaterAnalysis,
					ProductSeriesId: prodItem.ProductSeriesId,
					ProductSeriesName: prodItem.ProductSeriesName,
					IsRequired: prodItem.IsRequired
				};
				let product = {
					ServiceOrderObject: prodItem.WoObjectId, // 服务工单对象
					Barcode: prodItem.Barcode, // 物流码
					New_Barcode: "", //换机新物流码
					PurchaseDate: prodItem.PurchaseDate, // 购机日期
					Product: prodItem.ProuctId, // 产品
					Province: "", // 新省/市
					City: "", // 新市/区
					County: "", // 新区/县
					Street: "", // 新街道
					InstalledLocation: prodItem.InstallLocation, // 安装位置
					InstalledLocatuion_New: "", // 新安装位置
					SuitProductItems: "",
					Repairs: [],
					Maintains: maintains,
					MaintainType: prodItem.maintenanceIndex,
					WaterAnalysis: waterAnalysis
				};
				this.woProducts.push(product);
			}
		},
		CheckSpecial: function(str) {
			var containSpecial = RegExp(/[(\%)(\()(\))(\\)(\;)(\:)(\')(\")(\,)(\.)(\/)]+/);
			return (containSpecial.test(str));
		},
		//构建缓存信息
		GetCacheOrderInfo() {
			//工单信息
			this.woCacheData = {};
			this.woCacheData.FinishType = this.orderDetailData.WoFinishType; //完工类型
			this.woCacheData.Description = this.OrderRremark //备注
			this.woCacheData.RepairType = ""; //维修方式
			this.woCacheData.IsRepalced = false; //是否换件
			this.woCacheData.ActualReceivedAmount = this.ActualReceiptAmount; //实际收款总金额
			this.woCacheData.CustomerRequiresMaintenanceDate = this.CustomerRequiresMaintenanceDate; //客户服务时间
			this.woCacheData.WoProduct = []; //产品信息
			for (let index in this.orderDetailData.WoProuduct) {
				let prodItem = this.orderDetailData.WoProuduct[index];
				let waterAnalysis = {
					OriWaterAnalysisId: prodItem.OriWaterAnalysisId,
					OriTDS: prodItem.OriTDS,
					OriTemperature: prodItem.OriTemperature,
					OriHardness: prodItem.OriHardness,
					OriChlorine: prodItem.OriChlorine,
					NewTDS: prodItem.NewTDS,
					NewHardness: prodItem.NewHardness,
					NewChlorine: prodItem.NewChlorine,
					IsWaterAnalysis: prodItem.IsWaterAnalysis,
					ProductSeriesId: prodItem.ProductSeriesId,
					ProductSeriesName: prodItem.ProductSeriesName,
					IsRequired: prodItem.IsRequired,
					WaterAnalysisFieldRequired: prodItem.WaterAnalysisFieldRequired,
					IsShowWaterAnalysisAddBtn: prodItem.isShowWaterAnalysisAddBtn,
				};
				let prodImg; //图片
				if (prodItem.ProductImage) {
					prodImg = prodItem.ProductImage.replace("data:image/jpeg;base64,", "");
				}
				let product = {
					ServiceOrderObject: prodItem.WoObjectId, // 服务工单对象
					Barcode: prodItem.Barcode, // 物流码
					New_Barcode: "", //换机新物流码
					IsSerialValid: prodItem.IsSerialValid, //物流码有效性
					PurchaseDate: prodItem.PurchaseDate, // 购机日期
					Product: prodItem.ProuctId, // 产品
					ProdTypeGroup: prodItem.ProdTypeGroup, //产品类型
					ProductImage: prodImg, //图片
					ProductName: prodItem.ProductName, //产品名称
					ProductNum: prodItem.ProductNum, //产品编号
					Province: "", // 新省/市
					City: "", // 新市/区
					County: "", // 新区/县
					Street: "", // 新街道
					InstalledLocation: prodItem.InstallLocation, // 安装位置
					InstalledLocatuion_New: "", // 新安装位置
					SuitProductItems: "", //套装产品项
					Repairs: [], //维修信息
					Maintains: prodItem.ProductMaintainData, //保养信息
					MaintainType: prodItem.maintenanceIndex,
					WaterAnalysis: waterAnalysis //水质检测
				};
				this.woCacheData.WoProduct.push(product);
			}
			console.log(this.woCacheData);
			return JSON.stringify(this.woCacheData);
		},
		//给工单信息赋值
		AssignOrderInfo(woData) {
			this.OrderRremark = woData.WORemark; //备注
			this.CustomerRequiresMaintenanceDate = woData.CustomerRequiresMaintenanceDate ?
				woData.CustomerRequiresMaintenanceDate : ""; //客户产品日期
			this.ActualReceiptAmount = woData.ActualReceivedAmount ? woData.ActualReceivedAmount : ""; //实际金额
			//console.log("日期信息",this.CustomerRequiresMaintenanceDate,woData.CustomerRequiresMaintenanceDate);
		}

	},
}
